from time import*
f11 = open('m1_sorted.txt').readlines()
f22 = open('m2_reverse.txt').readlines()
f33 = open('m3_shuffle.txt').readlines()

f1 = list()
for y in range(len(f11)):
    f1.append(int(f11[y]))

f2 = list()
for x in range(len(f22)):
    f2.append(int(f22[x]))

f3 = list()
for z in range(len(f33)):
    f3.append(int(f33[z]))
    
time_1 = time()
for i in range (len(f1)-1):
    k = 0
    for j in range (len(f1)-i-1):
        if f1[j] > f1[j+1]:
            f1[j], f1[j+1] = f1[j+1], f1[j]
            k+=1
    if k == 0:
        break
time_2 = time()
t1 = time_2 - time_1
t1 *= 1000

time_12 = time()
for i in range (len(f2)-1):
    k = 0
    for j in range (len(f2)-i-1):
        if f2[j] > f2[j+1]:
            f2[j], f2[j+1] = f2[j+1], f2[j]
            k+=1
    if k == 0:
        break
time_22 = time()
t2 = time_22 - time_12
t2 *= 1000

time_13 = time()
for i in range (len(f3)-1):
    k = 0
    for j in range (len(f3)-i-1):
        if f3[j] > f3[j+1]:
            f3[j], f3[j+1] = f3[j+1], f3[j]
            k+=1
    if k == 0:
        break
time_23 = time()
t3 = time_23 - time_13
t3 *= 1000
print('m1_sorted', int(t1), 'milliseconds')
print('m2_reverse', int(t2), 'milliseconds')
print('m3_shuffle', int(t3), 'milliseconds')

